package com.hnnou.freshmenappserver.dao;

import com.hnnou.freshmenappserver.bean.Message;
import com.hnnou.freshmenappserver.bean.vo.MessagePageVo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface MessageDao {
    @Select("select * from t_message")
    List<Message> findAll();
    @Delete("delete from t_message where id=#{id}")
    int deleteById(int id);
    @Update("update t_message set title=#{title} ,content=#{content} ,date=#{date}" +
            " where id=#{id}")
    int update(Message message);
    @Insert("insert into t_message(name,content,date,title)"+
            " values(#{name},#{content},#{date},#{title})")
    int insert(Message message);

    @Select("select * from t_message where id=#{id}")
    Message selectById(int id);

    @Select("SELECT * FROM t_message limit #{offset}, #{pageSize}")
    List<Message> selectByPage(MessagePageVo messagePageVo);
}
